


function s(){
    //页面初次渲染的时候，小计会是每个商品的单价*数量
    let lists = document.querySelectorAll('#ml .organ');
    //总价
    let all = document.querySelector('#all');
    let allnum = 0;

    for (let i = 0; i < lists.length; i++){
        //console.log('单价');
        //console.log(lists[i].children[1].children[0].children[1].innerHTML);
        //console.log('数量');
        //console.log(lists[i].children[1].children[1].children[0].value);
        //console.log('小计');
        //console.log(lists[i].children[2].children[0].children[0].innerHTML);
        var dj = lists[i].children[1].children[0].children[1].innerHTML;
        var sl = lists[i].children[1].children[1].children[0].value;
        var xj = lists[i].children[2].children[0].children[0].innerHTML= dj * sl;
        console.log(xj);
        allnum += xj;

    }
    console.log(allnum);
    //1.页面初次渲染的时候，小计的总和赋给总价
    all.innerHTML = allnum.toFixed(2);
}
s();
//只要数量的input内容发生改变，小计和总价就会更新
let num_all = document.querySelectorAll("#ml .o-center .shuliang");
for(let j = 0; j < num_all.length; j++){
    num_all[j].addEventListener('change',s)
}
//删除操作之后，在根据小计计算总价
let del = document.querySelectorAll("#ml .o-right button");
for(let k = 0; k < del.length; k++){
 del[k].addEventListener('click',function(){
     console.log(this.parentNode.parentNode);
     console.log(del[k]);
     this.parentNode.parentNode.parentNode.parentNode.removeChild(this.parentNode.parentNode.parentNode);
    s()
 })
}